% these are the consumption warranties
% in HHW
function Cg = HHW_cg(Y,MU,CAPH,Nstates,rho,T,tolFP,maxreps)

MU_ins = MU;
Cf = Y(T)-MU_ins(:,:,T);
%Cf(end)=Y(end);
% Y same dimensions as MU
Nstates= size(CAPH,1);
Y = repmat(reshape(Y,1,1,T),Nstates,1);
%maxreps = 100;
%tolFP=0.005;
%rho=0.95;
for k=1:(T-1)
    t = T-k;
    Ct = fixedpointTmx_hhw_v1(CAPH,Y-MU_ins,rho,Cf,[],tolFP,maxreps);
    Cf = cat(3,Ct,Cf);
end

Cg = squeeze(Cf);

end

%[Ct Stay] = fixedpointTmx_hhw_v1(CAPH,Y-MU_ins,rho,Cf,[],tolFP,maxreps);
